<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">

    <title>账号注册-商户注册</title>
    <link rel="stylesheet" type="text/css" href="{{asset('css/home/reset.css')}}"/>
    <link rel="stylesheet" type="text/css" href="{{asset('css/home/style.css')}}"/>
    <link rel="stylesheet" href="{{asset('css/home/qy_style.css')}}">
    <link rel="shortcut icon" type="image/x-icon" href='{{asset('image/heeypay/anyun.ico')}}' media="screen" />
    <link rel="stylesheet" type="text/css" href="{{asset('css/heeypay/common.css')}}"  />


    <!-- jQuery文件。务必在bootstrap.min.js 之前引入 -->
    <script src="{{asset('js/buz/jquery.min.js')}}"></script>
    <script src="{{asset('js/buz/common.js')}}"></script>
    <script src="{{asset('vendor/bootstrap/js/bootstrapValidator.js')}}"></script>
    <!-- 最新的 Bootstrap 核心 JavaScript 文件 -->
    <script src="{{asset('vendor/bootstrap/js/bootstrap.min.js')}}"></script>
</head>
<body>
@include('layouts.home.header', ['active' => 'register', 'hideLogin' => true])
<!--content-->
<div class="content auto">
    <div class="regisbox regisbox3">
        <ul class="title">
            <li class="active">1.账号认证</li>
            <li>2.密码设置</li>
            <li>3.注册完成</li>
            <div class="cur"></div>
        </ul>
        <div class="regis regis3">
            <div class="clearfix">
                <img src="{{asset('image/home/succuss.png')}}" class="fl"/>
                <div class="fl ml10">
                    <p class="f16 title1">账号激活邮件已发送！</p>
                    <p class="f14">请进入您的邮箱,<a href="{{parseEmailUrl($credentials['username'])}}"><span class="bluezi f12">{{$credentials['username']}}</span></a>查收。</p>
                    <p class="f14">激活成功后可继续注册。</p>
                    <a href="{{parseEmailUrl($credentials['username'])}}" class="emailbtn f12">立即进入邮箱查收</a>
                </div>
            </div>
            {{--<div class="clearfix">--}}
                {{--<div class="fl email2">--}}
                    {{--<p class="f16">如果您还没有收到邮件</p>--}}
                    {{--<p class="f16">请先检查是否在您邮箱的垃圾邮件中，如果还是未收到邮件。</p>--}}
                    {{--<a href="javascript:void(0)" class="emailbtn f12">点击重新发送邮件</a>--}}
                {{--</div>--}}
            {{--</div>--}}
        </div>
    </div>
</div>
{{--警告弹窗--}}
<div class="modal fade in"  tabindex="-1" role="dialog" id="errorModel" aria-hidden="true">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-body">
                <h4 class="text-center"></h4>
            </div>
            <div class="modal-footer text-xs-center">
                <button type="button" class="btn btn-danger" data-dismiss="modal">确定</button>
            </div>
        </div>
    </div>
</div>
</body>

<script>
    $('#register').bootstrapValidator({
        message: '这个值没有被验证',
        feedbackIcons: {
            valid: 'glyphicon glyphicon-ok',
            invalid: 'glyphicon glyphicon-remove',
            validating: 'glyphicon glyphicon-refresh'
        },
        fields: {
            username: {
                message: '用户名不能为空',
                validators: {
                    notEmpty: {
                        message: '用户名不能为空'
                    },
                    regexp: {
                        regexp: /^([a-zA-Z0-9_-])+@([a-zA-Z0-9_-])+(.[a-zA-Z0-9_-])+/,
                        message: '请输入正确的邮箱'
                    }
                }
            },
            phone: {
                message: '手机不能为空',
                validators: {
                    notEmpty: {
                        message: '手机不能为空'
                    },
                    stringLength: {
                        min: 11,
                        max: 11,
                        message: '手机号码为11位'
                    },
                    regexp: {
                        regexp: /^1[3|5|7|8]\d{9}$/gi,
                        message: '请输入正确的手机号码'
                    },
                }
            },
            sms_code: {
                message: '验证码不能为空',
                validators: {
                    notEmpty: {
                        message: '验证码不能为空'
                    },
                    stringLength: {
                        min: 6,
                        max: 6,
                        message: '验证码长度为6位'
                    },
                    regexp: {
                        regexp: /^[0-9]*$/,
                        message: '验证码全为数字'
                    },
                }
            }
        }
    }).on('success.form.bv', function (e) {
        // Prevent form submission
        e.preventDefault();
        // Get the form instance
        var $form = $(e.target);
        // Get the BootstrapValidator instance
        var bv = $form.data('bootstrapValidator');

        $.post("/api/auth/register", $form.serialize(), function (data) {
            if (data.code == 0){
                window.location.href = '/register_email?username=' + $('#username').val();
            }else if(data.code == 40003){
                var str = "";
                var obj = data.message;
                $.each(obj,function(i){
                    var childObj = obj[i];
                    for(var j=0;j<childObj.length;j++){
                        str += childObj[j]+"<br/>";
                    }
                });
                showMsg(str);
            }else{
                showMsg(data.message);
            }
        });
    });

    /*下一步*/
    $("#forgetNext").click(function(e){
        $('#register').bootstrapValidator('validate');
    });
    //发送验证码
    $("#sendCode").click(function(){
        var _that = $(this);
        var bootstrapValidator = $('#register').data("bootstrapValidator");
        bootstrapValidator.validateField('phone');

        console.log(bootstrapValidator.isValidField('phone'))
        if(bootstrapValidator.isValidField('phone')){
            console.log("提交");
            var phone_txt = $("#phone").val();
            sendcode(phone_txt,1, _that);
        }
    });



</script>


</html>
